import { reqHotelInfo, reqHotelRoomInfo } from '@/api'
export default {
    actions: {
        async getHotelInfo({ dispatch, commit }, id) {
            let res = await reqHotelInfo(id)
            // console.log(res)
            if (res.code == 200) {
                commit('GETHOTELINFO', res.data[0])
                // dispatch('getRecommendInfo')
            }
        },
        async getRoomInfo({ commit }, id) {
            let res = await reqHotelRoomInfo(id)
            // console.log(res)
            if (res.code == 200) {
                commit('GETROOMINFO', res.data)
            }
        },
    },
    mutations: {
        GETHOTELINFO(state, data) {
            state.hotelInfo = data;
            state.city = state.hotelInfo.hotel_title.substring(0, 2);
            state.title = state.hotelInfo.hotel_title;
        },
        GETROOMINFO(state, data) {
            state.hotelRoomInfo = data;
        },
        submitOrder(state, data) {
            state.order = data
        },

    },
    state: {
        hotelInfo: {},
        hotelRoomInfo: [],
        order: {},
        city: '',
        title: ''
    },
    getters: {
    },
    modules: {
    }
}